home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
008a
/
scanasc.zip
/
SCANASC.DOC
next >
Wrap
Text File
|
1991-10-19
|
14KB
|
249 lines
SCANASC.DOC
SCANASC is a programmer's tool for quickly determining the scan
and ASCII codes of any key placed in the keyboard buffer by the ROM
BIOS. Code values are given in both decimal and hex. SCANASC
distinguishes between PC and enhanced keyboards and reports whether
the key is available only on the enhanced keyboard. Since codes are
like peanuts and potato chips--one rarely satisfies--SCANASC also
offers a List Mode. In List Mode SCANASC prepares a list of all the
keys you press in a session, their scan and ASCII codes, and
identifies those that are available only on the enhanced keyboard.
The syntax for running SCANASC is:
SCANASC [/M] [/L] [/H] [/?]
/H or /? for help.
/M to force SCANASC to run in monochrome when you have a color
monitor.
/L to operate SCANASC in List Mode. In List Mode, SCANASC
prepares a list of the scan and ASCII codes for all keystrokes
pressed. Output is placed in a file entitled SCANASC.LST in the
default directory. If SCANASC.LST exists, new output will be
appended to the end of the list. SCANASC.LST is presented in the
following sample format:
SCANASC.LST
Hex Decimal
Key Scan ASCII Scan ASCII Enhanced
---------------------------- ---- ----- ---- ----- --------
q 10 71 16 113
Backspace 0E 08 14 8
Num-Enter E0 0D 224 13 √
Home 47 00 71 0
Cursor Pad Home 47 E0 71 224 √
F12 86 00 134 0 √
Alt-F10 71 00 113 0
Alt-Esc 01 00 1 0 √
Ctrl-Numeric Keypad Center 8F 00 143 0 √
Alt-Numeric Keypad ({) 00 7B 0 123
Shift-F11 87 00 135 0 √
Numeric Keypad-5 4C 35 76 53
To exit SCANASC, press Esc twice. The first time Esc is pressed
the scan and ASCII codes for Esc are reported. The second key press
exits the program. If you do not wish to exit, but merely wish to
determine the Scan and ASCII codes for Esc, press any other key to
continue. Incidentally, although Ctrl-Esc and Shift-Esc generate the
same scan and ASCII codes as Esc (see below for more on this subject),
you must press Esc in its unshifted state to exit SCANASC.
When you run SCANASC, it first determines whether you have an
enhanced keyboard. If an enhanced keyboard is detected, a notice
"Enhanced Keyboard Detected" will appear, followed by box labelled
"Enhanced Key". If a key is available only on the enhanced keyboard,
a check mark (√) will appear in the box when the key is pressed.
The preceding examples from SCANASC.LST also demonstrate the
terminology employed by SCANASC to identify key names. The cursor
positioning keys on the numeric keypad are named without prefix. The
corresponding keys on the enhanced keyboard cursor pad are prefixed
"Cursor Pad". The middle key on the numeric keypad in its unshifted
state does not have a name. SCANASC calls it Numeric Keypad Center.
It is only recognized on enhanced keyboards. The numeric keys on the
keypad (i.e. when Num Lock is on or Shift is pressed, but not both)
are prefixed with "Numeric Keypad-" to distinguish them from the
numeric keys on the top row of the keyboard. Alt-Numeric Keypad ( )
refers to keys entered by holding down the Alt key and entering a
number between 1 and 255 on the numeric keypad. The ASCII character
generated by this procedure is given in parenthesis. The scan code
will always be 0 and the ASCII code will always be the number entered
on the numeric keypad.
Since SCANASC mirrors the idiosyncrasies of the ROM BIOS in terms
of keyboard translation, a few comments on those peculiarities may be
in order. The ROM BIOS does not recognize certain keys. For example,
although Ctrl-2, Ctrl-6, and Ctrl-_ are recognized, the other
printable keys on the top row of the keyboard are not recognized in
connection with the Ctrl key. Thus, if you press Ctrl-3 while in
SCANASC, nothing will happen. Other examples of unrecognized keys are
Ctrl-; and Ctrl-'. The only way to detect these keystrokes is through
interrupt 09H.
In some cases, the ROM BIOS will translate a key press as
unshifted, regardless of shift state. For example, Ctrl-Space, Shift-
Space, and Alt-Space are all interpreted as Space. Likewise, SCANASC
interprets each of these keys as "Space". Thus if you see that
SCANASC reports a shifted keystroke as if it were unshifted, this is a
cue that your program must independently check the shift state of the
key, either through one of the services offered by interrupt 16H, or
by examining the byte at 0040:0017H. Another example of disregarding
shift state occurs with Esc; Shift-Esc and Ctrl-Esc are both treated
as Esc. On an enhanced keyboard, however, Alt-Esc does generate a
unique code.
The ROM BIOS does not translate unique codes for shift key
combinations. Thus, if you press Ctrl-Alt-S, the ROM BIOS does not
generate a unique code. In my experience, the ROM BIOS observes the
following hierarchy: Alt, Ctrl, Shift. Thus, if Alt is pressed, it
takes precedence over both Ctrl and Shift. In the preceding example,
Ctrl-Alt-S would be treated as Alt-S. Having seen no mention of this
in the literature I have examined, I cannot say whether these
priorities constitute an absolute rule or represent the rules followed
by the BIOS on my own computer.
On some keyboards pressing two shift keys simultaneously will
inhibit the keyboard from generating a scan code for a printable key.
For example, on my Northgate keyboard, pressing Ctrl-Shift-Y
suppresses the generation of the Y scan code by the keyboard. On the
other hand, Ctrl-Shift-I is recognized. There is no way for a
programmer to detect when a keystroke is inhibited in this fashion.
Even trapping interrupt 9H will be of no avail. That may be the price
one pays for having function keys on the left.
SCANASC was written as an unintentional by-product of my program
MALT. MALT (More Alt-Keys for the Perfects) is a TSR that adds 90 new
keys to WordPerfect and other members of the Perfect family for
running Alt-like macros. To avoid conflicts with other TSRs, MALT
uses CapsLock + Key. In order for MALT to operate properly, it must
know if the user has reassigned the WordPerfect's "Macro Execute" key
(WordPerfect has a configurable keyboard), and, if so, to which key it
has been reassigned. I would guess that an infinitesimally small
number have reassigned this key, but, since I happen to be among that
small number, and, of course, in the interest of completeness, I wrote
a configuration program (MALTCFG) to allow for the customization of
MALT.
As it turned out, more effort was spent on MALTCFG than on MALT
itself. This is because MALTCFG had to recognize and interpret every
possible key supported by the ROM BIOS. Although information on
keyboard scan codes is readily available, none of the authorities I
consulted had a complete list of all the ROM BIOS scan and ASCII
codes. Not only was a list unavailable, but the assignment of the
codes does not follow any consistent logic, making it impossible in
many cases to deduce what a code should be. To remedy this
deficiency, I prepared a crude form of SCANASC. It seemed wasteful to
have spent all that effort on a program that few would use, so I
decided to develop SCANASC for the programming community.
Incidentally, after I completed MALTCFG, I discovered that the
setup procedure in the AMI BIOS has a keyboard utility that also
reports scan and ASCII codes. Inasmuch as the setup is in ROM, can
only be accessed by rebooting the computer, and has no List Mode,
there is probably still a place for SCANASC.
SCANASC is principally written in Microsoft Professional
Development System (PDS) BASIC 7.10, using routines contained in
Crescent Software's QuickPak Professional, and linked with Crescent's
P.D.Q. It also contains custom assembler routines by the author for
retrieving keystrokes. I would be unforgivably remiss if I failed to
underscore the importance of Crescent's products in the development of
this program. The fully commented assembly language source code
included with the Crescent products provided instructive examples for
the assembly language routines needed for SCANASC. An indispensable
education in assembly language programming was provided by Ethan
Winer's book "BASIC Techniques and Utilities".
I drew on a number of reference sources detailing the operation
of the keyboard and the ROM BIOS in connection with the preparation of
this program. Of these, by far the most instructive was the article
by Michael J. Mefford entitled "An In-depth Exploration of the PC
Keyboard and its Interrupt Service Routines", which appeared in the
May 1990 issue of Microsoft Systems Journal (Volume 5, Number 3). His
method for detecting the presence of an enhanced keyboard is
incorporated in SCANASC. Also very useful were the pair of articles
by Barry Simon (someone for whom I have a deep admiration because of
his work on CTRLALT and STACKEY) entitled "Learning Your Way Around
the Keyboard under DOS", which appeared in the December 25, 1990 and
January 15, 1991 issues of PC Magazine (Volume 9, Number 22 and Volume
10, Number 1). His program BIOSDATA, which was distributed with the
articles, was especially helpful in deciphering the operation of the
PC keyboard BIOS.
Two other informative resources were "DOS Programmer's Reference
(2nd Edition)", by Terry Dettmann and Jim Kyle, and "The New Peter
Norton Programmer's Guide to the IBM PC & PS/2", by Peter Norton and
Richard Wilton. I also referred frequently to "Advanced MS-DOS
Programming (Second Edition)", by Ray Duncan, but not for keyboard
information.
There is no charge or registration fee for the use of SCANASC. I
have benefited from many publicly distributed free programs and this
is a small way of reciprocating. I would enjoy hearing from anyone
who finds this program useful. I would particularly welcome
notification of any errors or omissions and suggestions for
improvement of the program.
If you use, or know of someone else who uses, WordPerfect, you
may wish to investigate my user supported programs. MALT has already
been described. In addition, I am the author of MPE4WP (Macro
Programming Environment for WordPerfect), a substitute for the
WordPerfect macro editor. MPE4WP permits the creation and editing of
macros on the WordPerfect editing screen or in any ASCII text editor.
MPE4WP includes programs that convert macros to and from text, macros
that improve upon the features of the macro editor, and enhancements
to the macro language.
This document and the program file SCANASC.EXE (the documentation
and program file are collectively referred to as the "Software") are
copyrighted by the author. You are licensed to use the Software; make
as many copies of the Software as you wish; give unaltered copies to
anyone; and distribute the Software via electronic means. There is no
charge for any of these uses.
You are, however, specifically prohibited from modifying the
Software or from distributing only a portion of it; charging, or
requesting donations, for any such copies; and from distributing the
Software with commercial products without prior permission. An
exception is granted to not-for-profit user's groups, which are
authorized to charge a small fee for materials, handling, postage, and
general overhead. No for-profit organization is authorized to charge
any amount for distribution of copies of the software, or to include
copies of the software with sales of its products.
This includes a specific prohibition against for-profit
organizations distributing the software, either alone or with other
software, and charging a "handling" or "materials" fee or any other
such fee for the distribution. No for-profit organization is
authorized to include the software on any mediium for which money is
charged. The preceding prohibition should not be construed as
applying to CompuServe, PCMagNet, or other similar services that have
general charges for connect time, and do not surcharge for downloading
this program.
There is no restriction on the use of the Software in commercial
or institutional environments.
The documentation and program file must be distributed together,
and this notice must not be removed.
By using this free Software, you agree that there is no warranty
of any kind, and the author is not liable to you or anyone else for
damages of any kind.
The Software is:
Copyright (c) 1991 by
Michael H. Shacter
7825 Marion Lane
Bethesda, Maryland 20814
CompuServe ID 76170,1627